package com.finance.rule.export;

import com.finance.util.export.ExcelHead;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;

@Data
public class NewWeightRuleImportTemplateBean {

    @ExcelHead(name="规则模式")
    private String patternRuleImport;
    private String patternRule;

    @ExcelHead(name="供应商名称")
    private String supplierCodeImport;
    private String supplierCode;

    @ExcelHead(name="承运商名称")
    private String  carrierCodeImport;
    private String  carrierCode;

    @ExcelHead(name="目的地省份")
    private String toProvinceImport;
    private String toProvince;

    @ExcelHead(name="目的市")
    private String toCityImport;
    private String toCity;

    @ExcelHead(name="发货省份")
    private String fromProvinceImport;
    private String fromProvince;

    @ExcelHead(name="发货城市")
    private String fromCityImport;
    private String fromCity;

    @ExcelHead(name="区域类型")
    private String regionIdImport;
    private String regionId;

    @ExcelHead(name="结算类型")
    private String settlementTypeImport;
    private String settlementType;

    @ExcelHead(name="左边界数值")
    private String pointLeft;

    @ExcelHead(name="右边界数值")
    private String pointRight;

    @ExcelHead(name="首重单价")
    private String firstPrice;

    @ExcelHead(name="续重单价")
    private String secondPrice;

    @ExcelHead(name="首重")
    private  String firstWeight;

    @ExcelHead(name="续重")
    private String secondWeight;

    @ExcelHead(name="代收款")
    private String cod;

    @ExcelHead(name="配送类型")
    private String direction;

    @ExcelHead(name="时效要求")
    private String expressScheduleType;

    @ExcelHead(name="温度级别")
    private String temperature;

    @ExcelHead(name="菜鸟驿站")
    private String cainiao;

    @ExcelHead(name="是否组包")
    private String isCombinedImport;
    private String isCombined;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof NewWeightRuleImportTemplateBean)) {
            return false;
        }
        NewWeightRuleImportTemplateBean that = (NewWeightRuleImportTemplateBean) o;
        if (null == supplierCodeImport ) {
            if(null != that.supplierCodeImport) {
                return false;
            }
        } else {
            if (!supplierCodeImport.equals(that.supplierCodeImport)) {
                return false;
            }
        }
       /* if (null == patternRuleImport ) {
            if(null != that.patternRuleImport) {
                return false;
            }
        } else {
            if (!patternRuleImport.equals(that.patternRuleImport)) {
                return false;
            }
        }*/
       if (null == carrierCodeImport ) {
            if(null != that.carrierCodeImport) {
                return false;
            }
        } else {
            if (!carrierCodeImport.equals(that.carrierCodeImport)) {
                return false;
            }
        }
        if (null == toProvinceImport ) {
            if(null != that.toProvinceImport) {
                return false;
            }
        } else {
            if (!toProvinceImport.equals(that.toProvinceImport)) {
                return false;
            }
        }
        if (null == toCityImport ) {
            if(null != that.toCityImport) {
                return false;
            }
        } else {
            if (!toCityImport.equals(that.toCityImport)) {
                return false;
            }
        }
        if (null == fromProvinceImport ) {
            if(null != that.fromProvinceImport) {
                return false;
            }
        } else {
            if (!fromProvinceImport.equals(that.fromProvinceImport)) {
                return false;
            }
        }
        if (null == fromCityImport ) {
            if(null != that.fromCityImport) {
                return false;
            }
        } else {
            if (!fromCityImport.equals(that.fromCityImport)) {
                return false;
            }
        }
        if (null == regionIdImport ) {
            if(null != that.regionIdImport) {
                return false;
            }
        } else {
            if (!regionIdImport.equals(that.regionIdImport)) {
                return false;
            }
        }
        if (null == settlementTypeImport ) {
            if(null != that.settlementTypeImport) {
                return false;
            }
        } else {
            if(!settlementTypeImport.equals(that.settlementTypeImport)) {
                return false;
            }
        }
        if (null == pointLeft ) {
            if(null != that.pointLeft) {
                return false;
            }
        } else {
            if(!pointLeft.equals(that.pointLeft)) {
                return false;
            }
        }
        if (null == pointRight ) {
            if(null != that.pointRight) {
                return false;
            }
        } else {
            if(!pointRight.equals(that.pointRight)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = 2;
        result = 31 * result + (null == supplierCodeImport ? 1: supplierCodeImport.hashCode());
        result = 31 * result + (null == carrierCodeImport ? 1: carrierCodeImport.hashCode());
        //result = 31 * result + (null == patternRuleImport ? 1: patternRuleImport.hashCode());
        result = 31 * result + (null == toProvinceImport ? 1: toProvinceImport.hashCode());
        result = 31 * result + (null == toCityImport ? 1 : toCityImport.hashCode());
        result = 31 * result + (null == fromProvinceImport ? 1: fromProvinceImport.hashCode());
        result = 31 * result + (null == fromCityImport ? 1 : fromCityImport.hashCode());
        result = 31 * result + (null == regionIdImport ? 1 : regionIdImport.hashCode());
        result = 31 * result + (null == settlementTypeImport?1:settlementTypeImport.hashCode());
        result = 31 * result + (null == pointLeft ? 1 : pointLeft.hashCode());
        result = 31 * result + (null == pointRight ? 1 : pointRight.hashCode());
        return result;
    }

    public NewWeightRuleExcel toNewWeightRuleExcel(){
        NewWeightRuleExcel newWeightRule = new NewWeightRuleExcel();
        newWeightRule.setSupplierCodeImport(this.getSupplierCodeImport());
        newWeightRule.setCarrierCodeImport(this.getCarrierCodeImport());
        //newWeightRule.setPatternRuleImport(this.getPatternRuleImport());
        newWeightRule.setToProvinceImport(this.getToProvinceImport());
        newWeightRule.setToCityImport(this.getToCityImport());
        newWeightRule.setFromProvinceImport(this.getFromProvinceImport());
        newWeightRule.setFromCityImport(this.getFromCityImport());
        newWeightRule.setRegionIdImport(this.getRegionIdImport());
        newWeightRule.setSettlementTypeImport(this.getSettlementTypeImport());

        newWeightRule.setPointLeft(StringUtils.isNotBlank(this.getPointLeft())? new BigDecimal(this.getPointLeft()):null);
        newWeightRule.setPointRight(StringUtils.isNotBlank(this.getPointRight())? new BigDecimal(this.getPointRight()):null);
        newWeightRule.setFirstPrice(StringUtils.isNotBlank(this.getFirstPrice())? new BigDecimal(this.getFirstPrice()):null);
        newWeightRule.setSecondPrice(StringUtils.isNotBlank(this.getSecondPrice())? new BigDecimal(this.getSecondPrice()):null);
        newWeightRule.setFirstWeight(StringUtils.isNotBlank(this.getFirstWeight())? new BigDecimal(this.getFirstWeight()):null);
        newWeightRule.setSecondWeight(StringUtils.isNotBlank(this.getSecondWeight())? new BigDecimal(this.getSecondWeight()):null);
        newWeightRule.setCod(StringUtils.isNotBlank(this.getCod())? new BigDecimal(this.getCod()):null);
        newWeightRule.setDirection(StringUtils.isNotBlank(this.getDirection())? new BigDecimal(this.getDirection()):null);
        newWeightRule.setExpressScheduleType(StringUtils.isNotBlank(this.getExpressScheduleType())? new BigDecimal(this.getExpressScheduleType()):null);
        newWeightRule.setTemperature(StringUtils.isNotBlank(this.getTemperature())? new BigDecimal(this.getTemperature()):null);
        newWeightRule.setCainiao(StringUtils.isNotBlank(this.getCainiao())? new BigDecimal(this.getCainiao()):null);
        newWeightRule.setIsCombinedImport(this.getIsCombinedImport());
        return newWeightRule;
    }
}
